package timing.ukulele.oss.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import timing.ukulele.oss.UkuleleOSSTemplate;
import timing.ukulele.oss.UkuleleS3Client;

/**
 * springboot自动装配类
 * @author 11697
 */
@Configuration
@EnableConfigurationProperties(OSSProperties.class)
@ConditionalOnProperty(name= "ukulele.oss.enabled", havingValue="true")
public class AutoConfiguration {
    @Autowired
    private OSSProperties ossProperties;

    @Bean
    @ConditionalOnMissingBean
    public UkuleleOSSTemplate ukuleleOSSTemplate(){
        return new UkuleleS3Client(this.ossProperties);
    }
}
